package com.thunder.rebot.rebotclient.view;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.nfc.NfcAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.thunder.rebot.rebotclient.R;
import com.thunder.rebot.rebotclient.iml.OnTvClickListener;

public class CustomPopwindow extends PopupWindow {
    private OnTvClickListener onTvClickListener;
    public void setTvOnclickListener(OnTvClickListener onclickListener){
        this.onTvClickListener = onclickListener;
    }
    public CustomPopwindow(Context context,int res, int bg) {
        super(context);
        setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
        setOutsideTouchable(true);
        setFocusable(true);
        setBackgroundDrawable(context.getResources().getDrawable(bg));
        View contentView = LayoutInflater.from(context).inflate(res, null, false);
        TextView tvEnd = contentView.findViewById(R.id.tvEnd);
        TextView tvStart = contentView.findViewById(R.id.tvStart);
        tvEnd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onTvClickListener.tvClickListener(v);
            }
        });
        tvStart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onTvClickListener.tvClickListener(v);
            }
        });
        setContentView(contentView);
    }
}
